package com.bwie.controller;
import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.service.impl.UserServiceImpl;
import com.bwie.utils.R;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
* (t_user)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/user/index")
public class UserController {
/**
* 服务对象
*/
    @Autowired
    private UserService userService;

    /**
     * @author: 秋晚
     * @description:登录方法
     * @params: [com.bwie.pojo.User]
     * @return: com.bwie.utils.R
     * @date: 2025/7/7 11:19
     */
    @PostMapping("login")
    public R login(@RequestBody User user){
        return userService.login(user);
    }

    @PostMapping("getAllUser")
    public R getAllUser(){
        return userService.getAllUser();
    }

    /**
     * @author: 秋晚
     * @description:根据id查询用户
     * @params: [java.lang.Integer]
     * @return: com.bwie.utils.R
     * @date: 2025/7/10 14:11
     */
    @PostMapping("getUserById/{id}")
    public R getUserById(@PathVariable(name = "id") Long id){
        User user = userService.getById(id);
        return R.OK(user);
    }

}
